from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.common.keys import Keys
import requests

br = webdriver.Edge()
br.maximize_window()
br.get("https://mail.qq.com/")
sleep(1)
# ptlogin_iframe
# html = br.find_element(br.TAG_NAME,"iframe")
# sleep(1)
# br.switch_to.frame(br.find_element(br.CLASS_NAME,"QQMailSdkTool_login_loginBox_qq_iframe"))
# sleep(1)
# br.switch_to.frame(br.find_element(br.ID,"ptlogin_iframe"))
# sleep(1)
frameList = br.find_elements(By.TAG_NAME,"iframe")
br.switch_to.frame(frameList[1])
br.switch_to.frame("ptlogin_iframe")
sleep(1)
br.find_element(By.XPATH,'//*[@id="switcher_plogin"]').click()

br.find_element(By.XPATH,'//*[@id="u"]').send_keys("123456789")
br.find_element(By.XPATH,'//*[@id="p"]').send_keys("123456789")

sleep(1)
br.find_element(By.XPATH,'//*[@id="login_button"]').click()
sleep(2)
# br.find_element(By.XPATH,'//[*id="newVcodeArea"]') #('./1.png')
# br.get_screenshot_as_file("1.jpg")
img = br.find_element(By.XPATH,'//[*id="newVcodeArea"]').screenshot_as_base64

token = "9HpxbFcDwVTCcbWQQbStmnE2unz7yO8jGSKc7C8ImMA"
url = "http://api.jfbrm.com/api/YmServer/customApi"
type = "50013"

_headers = {
        "Content-Type": "application/json"
    }
data = {
        ## 关于参数,一般来说有3个;不同类型id可能有不同的参数个数和参数名,找客服获取
        "token": token,
        "type": type,
        "image": img,
    }
requests.post(url,json=data)